/* glcd.h

Copyright (C) Alex S. (mailto: md5sum@alexsp.ru)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details
http://www.gnu.org/licenses/gpl-2.0.html.

You should have received a copy of the GNU General Public License
along with this program in the file gpl-2.0.txt;
if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/


#ifndef GLCD_H_
#define GLCD_H_

#include <avr/pgmspace.h>

#define USARTBAUD 38400L


#define GLCD_PORTx PORTA
#define GLCD_DDRx DDRA
#define GLCD_PINx PINA

#define GLCD_contr PORTC
#define GLCD_contr_ddr DDRC

#define GLCD_CSA (1<<2)
#define GLCD_CSB (1<<3)
#define GLCD_RS (1<<4)
#define GLCD_RW (1<<5)
#define GLCD_E (1<<6)
#define GLCD_RST (1<<7)

#define GLCD_busy (1<<7)
#define GLCD_read() (GLCD_contr|=GLCD_RW)
#define GLCD_write() (GLCD_contr&=~GLCD_RW)

void GLCD_init();
void GLCD_xy(const uint8_t x, const uint8_t y);
void GLCD_clear();
void GLCD_print_mem(const prog_uint8_t *c,const uint8_t len, const uint8_t offset, const uint8_t mask);
void GLCD_put_data(const uint8_t data);
void GLCD_print_5x8(const uint8_t c, const uint8_t offset, uint8_t space);
void GLCD_print_3x5(const uint8_t c, const uint8_t offset, uint8_t space);
void GLCD_print_10x16(const uint8_t c, const uint8_t offset, uint8_t space);
void GLCD_print_12x16(const uint8_t c, const uint8_t offset, uint8_t space);
uint8_t GLCD_get_data();

void GLCD_print_logo(const uint8_t offset,uint16_t baud);

#define load_x 0
#define read_x 64
void print_load_addr(uint16_t a);
void print_read_addr(uint16_t a);

#endif /* GLCD_H_ */
